package com.gouwudai.gobbs.util;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * 备份数据库
 * @author <a href="mailto:littcai@hotmail.com">空心大白菜</a>
 * @date 2006-09-07
 * @version 1.0
 */
public class BackupDB {
    
    private String filePath = "";
    private String fileName = "";
    private String message = "";
    
    /**
     * MS SQL SERVER备份
     * @param con
     * @param stmt
     * @param dbName 备份文件名自动按天备份
     * @param filePath 备份文件存放绝对路径
       */
    public boolean sqlServerBackup(Connection con, Statement stmt, String dbName){
        boolean bea =  true;
        String sql = "BACKUP DATABASE ["+dbName+"] TO DISK = N'";
        sql += filePath + fileName;
        sql += "' WITH  NOINIT ,  NOUNLOAD ,  NAME = N'lvdong',  NOSKIP ,  STATS = 10,  NOFORMAT";
        try {
            stmt = con.createStatement();
            stmt.executeUpdate(sql);
        }catch(SQLException e) {
            bea = false;
            e.printStackTrace();
            message = e.toString();
        }
        return bea;
    }
    
    public String getMessage() {
        return message;
    }

    public String getFileName() {
        return fileName;
    }
    public void setFileName(String fileName) {
        this.fileName = fileName;
    }
    public String getFilePath() {
        return filePath;
    }
    public void setFilePath(String filePath) {
        this.filePath = filePath;
    }

}
